package com.ipt.frm.pw;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class SessionInfo extends ServletMaestro {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession(true);
		out.println("<html>");
		out.println("<body>");
		out.println("<head>");
		out.println("<title>Pagina con los aprametros de session</title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<h3>Ejemplo de parametros recibidos por request con el metodo get</h3>");

		out.println("Fecha de creacion: " + session.getCreationTime() + "<br/>");
		session.setAttribute("saludo", session.getAttribute("nombre"));
		session.setAttribute("user", "admin");
		out.println("Informacion del servidor: "
				+ session.getServletContext().getServerInfo() + "<br/>");
		out.println("<a href=\"index.jsp\" >Volver </a><br/>");

		out.println("</body>");
		out.println("</html>");
	}

	/**
	 * We are going to perform the same operations for POST requests as for GET
	 * methods, so this method just sends the request to the doGet method.
	 */

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		doGet(request, response);
	}
}
